﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;

namespace PlaneGame
{
    /// <summary>
    /// 玩家飞机的子弹
    /// </summary>
    public class Bullet:GameObject
    {
        public Bullet(int x,int y,int angle):base(x,y,Properties.Resources.bul02)
        {
            X = x;
            Y = y;
            Angle = angle;
            switch (Angle)
            {
                case 0:
                    img = Properties.Resources.bul02;
                    Y -= 17;
                    break;
                case 30:
                    img = Properties.Resources.bul02_30;
                    X += 12;
                    Y -= 12;
                    break;
                case 60:
                    img = Properties.Resources.bul02_60;
                    X += 2;
                    Y -= 17;
                    break;
                case 120:
                    img = Properties.Resources.bul02_120;
                    X -= 35;
                    Y -= 12;
                    break;
                case 150:
                    img = Properties.Resources.bul02_150;
                    X -= 20;
                    Y -= 12;
                    break;
                default:
                    break;
            }
        }

        /// <summary>
        /// 子弹移动的方法
        /// </summary>
        public void Move()
        {
            //玩家的子弹是向上运行的  所以它的纵坐标应该是减小的
            this.Y = this.Y - 40;
            if (this.Y<0)
            {
                //说明这颗子弹已经跑到屏幕外边去了，我们要在内存当中移除它
                DataUtil.bulletList.Remove(this);
            }
        }
        
        //但是继承下来的Draw不能够满足我们的方法
        //在c#里面，所有的虚方法都可以被重写

        public override void Draw(Graphics g)
        {
            this.Move();
            base.Draw(g);  //调父类方法

          
        }

        
    }
}
